package com.itheima.prameter;

public class MothodTest3 {
    public static void main(String[] args) {
        //完成打印int类型数组的元素
        int[] arr = {1, 2, 3};
        printArray(arr);

        int[] arr2 =null;
        printArray(arr2);
    }

    public static void printArray(int[] arr) {

        if(arr == null){
            System.out.println(arr);
            return;
        }
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            /*if (i == arr.length - 1) {
                System.out.print(arr[i]);
            } else {
                System.out.print(arr[i] + ", ");
            }*/
            System.out.print(arr[i] + (i == arr.length - 1 ? "" : ", "));

        }
        System.out.println("]");
    }
}
